package com.tanhua.server.controller;

import com.tanhua.model.dto.OptionDto;
import com.tanhua.model.vo.NairVo;
import com.tanhua.model.vo.ReportVo;
import com.tanhua.server.serivce.TestSoulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/testSoul")
public class TestSoulController {
    @Autowired
    private TestSoulService testSoulService;
    @GetMapping
    public ResponseEntity testSoul(){
        List<NairVo> nairVo = testSoulService.testSoul();
        return ResponseEntity.ok(nairVo);
    }
    @PostMapping
    public ResponseEntity sendResult(@RequestBody Map<String,List<OptionDto>> map){
        List<OptionDto> list = map.get("answers");
        String reportId = testSoulService.sendResult(list);
        return ResponseEntity.ok(reportId);
    }

    @GetMapping("/report/{id}")
    public ResponseEntity report(@PathVariable Long id){
        ReportVo vo = testSoulService.report(Integer.valueOf(id.toString()));
        return ResponseEntity.ok(vo);
    }
}
